const baseURL = '/xaas-api'

function getYear () {
  const date = new Date()
  const year = date.getFullYear()
  return year.toString()
}

function dictUrl (code) {
  return baseURL + '/cfg-api/cfgDictItem/content?code=' + code
}

let defaultSetting = {
  clientId: 'saas',
  clientSecret: '123456',
  sessionName: 'XAAS_SESSION',
  baseURL: baseURL,
  authUrl: baseURL + '/auth-api',
  ucUrl: baseURL + '/uc-api',
  cfgUrl: baseURL + '/cfg-api',
  dictUrl,
  copyName: 'chirspan',
  copyRight: '2021 - ' + getYear(),
  copyContact: '',
  superAdminRole: 'ROLE_SUPER_ADMIN'
}

export default defaultSetting

export const useSetting = (setting) => {
  defaultSetting = Object.assign(defaultSetting, setting || {})
}
